package  {
	
	import mz.behaveas.model.expectation.Expectation;
	import mz.behaveas.model.expectation.ExpectationFactory;
	
/**
 * @author maxim.zaks@gmail.com
 */
public const ExpectationSpec : * = {
	description:"Check behaviour of Expectations",
	expectations:[
		{
			description:"Malformed Expectations behaves false",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({});
				return exp.isCorrect; 
			},
			shouldEqual:false
		},
		{
			description:"Unimplemented Expectations behaves as correct",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"hallo"});
				return exp.isCorrect; 
			},
			shouldEqual:true
		},
		{
			description:"Ignored Expectation behaves always as correct",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", ignore:"doesn't matter", behaviour:onePlusOne, shouldEqual:3});
				return exp.isCorrect; 
			},
			shouldEqual:true
		},	
		{
			description:"Behaves as expected for should equal",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:onePlusOne, shouldEqual:2});
				return exp.isCorrect; 
			},
			shouldEqual:true
		},	
		{
			description:"Behaves not as expected for should equal",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:onePlusOne, shouldEqual:1});
				return exp.isCorrect; 
			},
			shouldEqual:false
		},	
		{
			description:"Behaves not as expected for should equal because of Exception",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:throwError, shouldEqual:1});
				return exp.isCorrect; 
			},
			shouldEqual:false
		},	
		{
			description:"Behaves as expected for should not equal",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:onePlusOne, shouldNotEqual:3});
				return exp.isCorrect; 
			},
			shouldEqual:true
		},	
		{
			description:"Behaves not as expected for should not equal",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:onePlusOne, shouldNotEqual:2});
				return exp.isCorrect; 
			},
			shouldEqual:false
		},	
		{
			description:"Behaves not as expected for should not equal because of exception",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:throwError, shouldNotEqual:2});
				return exp.isCorrect; 
			},
			shouldEqual:false
		},	
		{
			description:"Behaves as expected for should throw",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:throwError, shouldThrow:Error});
				return exp.isCorrect;
			},
			shouldEqual:true
		},	
		{
			description:"Behaves not as expected for should throw because of wrong ErrorType",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:throwError, shouldThrow:TypeError});
				return exp.isCorrect;
			},
			shouldEqual:false
		},	
		{
			description:"Behaves as expected for shold equal on two equal arrays",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:returnArray, shouldEqual:[1,2,3]});
				return exp.isCorrect;
			},
			shouldEqual:true
		},
		{
			description:"Behaves as expected for shold equal on two not equal arrays. One array is a subset of the over",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:returnArray, shouldEqual:[1,2,3,4]});
				return exp.isCorrect;
			},
			shouldEqual:false
		},
		{
			description:"Behaves as expected for shold equal on two not equal arrays. Arrays have the same number of entries but different values",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:returnArray, shouldEqual:[1,2,4]});
				return exp.isCorrect;
			},
			shouldEqual:false
		},
		{
			description:"Behaves as expected for shold not equal on two equal arrays",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:returnArray, shouldNotEqual:[1,2,3]});
				return exp.isCorrect;
			},
			shouldEqual:false
		},
		{
			description:"Behaves as expected for shold not equal on two not equal arrays. One array is a subset of the over",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:returnArray, shouldNotEqual:[1,2,3,4]});
				return exp.isCorrect;
			},
			shouldEqual:true
		},
		{
			description:"Behaves as expected for shold not equal on two not equal arrays. Arrays have the same number of entries but different values",
			behaviour:function():Boolean{
				var exp : Expectation = ExpectationFactory.createExpectation({description:"test", behaviour:returnArray, shouldNotEqual:[1,2,4]});
				return exp.isCorrect;
			},
			shouldEqual:true
		}
	
	]
};
}

function onePlusOne():int {
	return 1+1;
}
function throwError():int {
	throw Error("interrupt behaviour");
	return 1+1;
}
function returnArray():Array {
	return [1,2,3];
}